#ifndef CORE_H
#define CORE_H

#include <QObject>
#include <QSharedPointer>

#include "view/View.h"
#include "com/SocketServer.h"
#include "com/SocketClient.h"
#include "item/Item.h"

namespace br {
namespace org {
namespace core {

using namespace br::org::view;
using namespace br::org::item;

class Core : public QObject
{
    Q_OBJECT
public:    
    ViewPtr view;

    virtual ~Core();
    virtual void add( Item* item );
    void showView();    
    void startCom( QHostAddress hostServer , qint16 portServer, QHostAddress hostClient , qint16 portClient );
    static Core* get();

protected:
    Core();

private:
    static Core* instance;
    SocketClient* socketClient;
    SocketServer* socketServer;
    QTimer* timer;

    void configureLoop();

private slots:
    void receive();

};

typedef QSharedPointer< Core > CorePtr;

} // namespace core
} // namespace org
} // namespace br

#endif // CORE_H
